/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package VIEW;

import BEANS.ComboItem;
import CONTROLLERS.DeliveryController;
import UTIL.InputValidator;
import java.awt.event.KeyEvent;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTable;

/**
 *
 * @author Belthazod
 */
public class DeliveryUI extends javax.swing.JPanel {
    static DeliveryController deliveryController;
    /**
     * Creates new form Delivery
     */
    public DeliveryUI() {
        initComponents();
        dateTo.setFormat(0);
        dateFrom.setFormat(0);
        
        deliveryProductsTable.getColumnModel().getColumn(0).setMaxWidth(0);
        deliveryProductsTable.getColumnModel().getColumn(0).setMinWidth(0);
        deliveryProductsTable.getColumnModel().getColumn(0).setPreferredWidth(0);
        
        deliveryProductsTable.getColumnModel().getColumn(5).setMaxWidth(0);
        deliveryProductsTable.getColumnModel().getColumn(5).setMinWidth(0);
        deliveryProductsTable.getColumnModel().getColumn(5).setPreferredWidth(0);
        deliveryController = new DeliveryController(productTableSearchInput, clear, deliveryProductsTable, 
                deliveryTable, productFilterCategoryComboBox, deliveryProductFilterSupplierComboBox, deliverySupplierLabel, 
                deliverySupplierIDLabel, inputQuantityDialog, inputQuantityTextField, editQuantity, editQuantityDialog, 
                deliveryReceiptInput, remarksInput, deliveryHistoryTable, dateTo, dateFrom, dateChooserCombo1);
        InputValidator.enabler(deliveryProductsTable, addToListButton);
        InputValidator.enabler(deliveryTable, removeFromListButton);
        InputValidator.enabler(deliveryTable, editButton);
        deliveryController.justDClickIt(deliveryProductsTable);
        deliveryController.justDClickIt2(deliveryTable);
        inputQuantityDialog.setLocationRelativeTo(null);
        editQuantityDialog.setLocationRelativeTo(null);
        deliveryHistoryDialog.setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        inputQuantityDialog = new javax.swing.JDialog();
        inputQuantityTextField = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        quantityCancelButton = new javax.swing.JButton();
        quantityInputButton = new javax.swing.JButton();
        editQuantityDialog = new javax.swing.JDialog();
        editQuantity = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        editQuantityCancel = new javax.swing.JButton();
        editQuantityOKButton = new javax.swing.JButton();
        DeliveryReceipt = new javax.swing.JDialog();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        deliveryHistoryDialog = new javax.swing.JDialog();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        deliveryHistoryTable = new javax.swing.JTable();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        dateTo = new datechooser.beans.DateChooserCombo();
        dateFrom = new datechooser.beans.DateChooserCombo();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        deliveryProductsTable = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        deliveryTable = new javax.swing.JTable();
        clear = new javax.swing.JLabel();
        removeFromListButton = new javax.swing.JButton();
        saveDeliveryButton = new javax.swing.JButton();
        addToListButton = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        deliveryProductFilterSupplierComboBox = new javax.swing.JComboBox<ComboItem>();
        jLabel5 = new javax.swing.JLabel();
        deliverySupplierLabel = new javax.swing.JLabel();
        dateChooserCombo1 = new datechooser.beans.DateChooserCombo();
        jLabel6 = new javax.swing.JLabel();
        deliverySupplierIDLabel = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        productFilterCategoryComboBox = new javax.swing.JComboBox<ComboItem>();
        productTableSearchInput = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        clearTableButton = new javax.swing.JButton();
        editButton = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        deliveryReceiptInput = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        remarksInput = new javax.swing.JTextArea();
        jSeparator1 = new javax.swing.JSeparator();
        jButton4 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();

        inputQuantityDialog.setTitle("Input Quantity");
        inputQuantityDialog.setBounds(new java.awt.Rectangle(0, 0, 250, 130));
        inputQuantityDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
        inputQuantityDialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                inputQuantityDialogWindowClosed(evt);
            }
        });

        inputQuantityTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inputQuantityTextFieldActionPerformed(evt);
            }
        });
        inputQuantityTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                inputQuantityTextFieldKeyPressed(evt);
            }
        });

        jLabel9.setText("Enter quantity:");

        quantityCancelButton.setText("Cancel");
        quantityCancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quantityCancelButtonActionPerformed(evt);
            }
        });

        quantityInputButton.setText("OK");
        quantityInputButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quantityInputButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout inputQuantityDialogLayout = new javax.swing.GroupLayout(inputQuantityDialog.getContentPane());
        inputQuantityDialog.getContentPane().setLayout(inputQuantityDialogLayout);
        inputQuantityDialogLayout.setHorizontalGroup(
            inputQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(inputQuantityDialogLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel9)
                .addGap(26, 26, 26)
                .addComponent(inputQuantityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(53, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, inputQuantityDialogLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(quantityInputButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(quantityCancelButton)
                .addGap(30, 30, 30))
        );
        inputQuantityDialogLayout.setVerticalGroup(
            inputQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(inputQuantityDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(inputQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(inputQuantityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                .addGroup(inputQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(quantityInputButton)
                    .addComponent(quantityCancelButton))
                .addContainerGap())
        );

        editQuantityDialog.setTitle("Edit Quantity");
        editQuantityDialog.setBounds(new java.awt.Rectangle(0, 0, 250, 130));
        editQuantityDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
        editQuantityDialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                editQuantityDialogWindowClosed(evt);
            }
        });

        editQuantity.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editQuantityActionPerformed(evt);
            }
        });
        editQuantity.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                editQuantityKeyPressed(evt);
            }
        });

        jLabel10.setText("Enter quantity:");

        editQuantityCancel.setText("Cancel");
        editQuantityCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editQuantityCancelActionPerformed(evt);
            }
        });

        editQuantityOKButton.setText("OK");
        editQuantityOKButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editQuantityOKButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout editQuantityDialogLayout = new javax.swing.GroupLayout(editQuantityDialog.getContentPane());
        editQuantityDialog.getContentPane().setLayout(editQuantityDialogLayout);
        editQuantityDialogLayout.setHorizontalGroup(
            editQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editQuantityDialogLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel10)
                .addGap(26, 26, 26)
                .addComponent(editQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(45, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, editQuantityDialogLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(editQuantityOKButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(editQuantityCancel)
                .addGap(30, 30, 30))
        );
        editQuantityDialogLayout.setVerticalGroup(
            editQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editQuantityDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(editQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(editQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addGroup(editQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(editQuantityOKButton)
                    .addComponent(editQuantityCancel))
                .addContainerGap())
        );

        DeliveryReceipt.setTitle("Delivery Receipt");
        DeliveryReceipt.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Delivery Receipt:");

        jTextField1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jButton2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton2.setText("Cancel");

        jButton3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton3.setText("OK");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout DeliveryReceiptLayout = new javax.swing.GroupLayout(DeliveryReceipt.getContentPane());
        DeliveryReceipt.getContentPane().setLayout(DeliveryReceiptLayout);
        DeliveryReceiptLayout.setHorizontalGroup(
            DeliveryReceiptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DeliveryReceiptLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(DeliveryReceiptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(DeliveryReceiptLayout.createSequentialGroup()
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2))
                    .addGroup(DeliveryReceiptLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(43, Short.MAX_VALUE))
        );
        DeliveryReceiptLayout.setVerticalGroup(
            DeliveryReceiptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DeliveryReceiptLayout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addGroup(DeliveryReceiptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(80, 80, 80)
                .addGroup(DeliveryReceiptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        deliveryHistoryDialog.setTitle("Delivery History");
        deliveryHistoryDialog.setBounds(new java.awt.Rectangle(0, 0, 900, 600));
        deliveryHistoryDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel13.setText("Delivery History");

        deliveryHistoryTable.setAutoCreateRowSorter(true);
        deliveryHistoryTable.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        deliveryHistoryTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Date", "Product Name", "Quantity", "Receipt Number", "Remarks"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        deliveryHistoryTable.setRowHeight(20);
        jScrollPane4.setViewportView(deliveryHistoryTable);

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel14.setText("From:");

        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel15.setText("To:");

        dateTo.setWeekStyle(datechooser.view.WeekDaysStyle.FULL);
        dateTo.addSelectionChangedListener(new datechooser.events.SelectionChangedListener() {
            public void onSelectionChange(datechooser.events.SelectionChangedEvent evt) {
                dateToOnSelectionChange(evt);
            }
        });
        dateTo.addCommitListener(new datechooser.events.CommitListener() {
            public void onCommit(datechooser.events.CommitEvent evt) {
                dateToOnCommit(evt);
            }
        });

        dateFrom.setWeekStyle(datechooser.view.WeekDaysStyle.FULL);
        dateFrom.addSelectionChangedListener(new datechooser.events.SelectionChangedListener() {
            public void onSelectionChange(datechooser.events.SelectionChangedEvent evt) {
                dateFromOnSelectionChange(evt);
            }
        });
        dateFrom.addCommitListener(new datechooser.events.CommitListener() {
            public void onCommit(datechooser.events.CommitEvent evt) {
                dateFromOnCommit(evt);
            }
        });

        javax.swing.GroupLayout deliveryHistoryDialogLayout = new javax.swing.GroupLayout(deliveryHistoryDialog.getContentPane());
        deliveryHistoryDialog.getContentPane().setLayout(deliveryHistoryDialogLayout);
        deliveryHistoryDialogLayout.setHorizontalGroup(
            deliveryHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(deliveryHistoryDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(deliveryHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, deliveryHistoryDialogLayout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dateFrom, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dateTo, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        deliveryHistoryDialogLayout.setVerticalGroup(
            deliveryHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(deliveryHistoryDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel13)
                .addGap(18, 18, 18)
                .addGroup(deliveryHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(dateTo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dateFrom, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 505, Short.MAX_VALUE)
                .addContainerGap())
        );

        setBackground(new java.awt.Color(204, 204, 204));
        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Delivery Acknowledgement");
        add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 1090, -1));

        deliveryProductsTable.setAutoCreateRowSorter(true);
        deliveryProductsTable.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        deliveryProductsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "Product ID", "Product Name", "Category", "Supplier", "Current Quantity", "ReorderQuantity Level", "Supplier ID"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        deliveryProductsTable.setRowHeight(20);
        deliveryProductsTable.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                deliveryProductsTableKeyPressed(evt);
            }
        });
        jScrollPane1.setViewportView(deliveryProductsTable);
        if (deliveryProductsTable.getColumnModel().getColumnCount() > 0) {
            deliveryProductsTable.getColumnModel().getColumn(4).setMaxWidth(70);
            deliveryProductsTable.getColumnModel().getColumn(5).setMaxWidth(70);
        }

        add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 119, 530, 490));

        deliveryTable.setAutoCreateRowSorter(true);
        deliveryTable.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        deliveryTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Product ID", "Product Name", "Supplier", "Quantity "
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        deliveryTable.setRowHeight(20);
        jScrollPane2.setViewportView(deliveryTable);
        if (deliveryTable.getColumnModel().getColumnCount() > 0) {
            deliveryTable.getColumnModel().getColumn(3).setMaxWidth(70);
        }
        deliveryTable.getColumnModel().getColumn(0).setMaxWidth(0);
        deliveryTable.getColumnModel().getColumn(0).setMinWidth(0);
        deliveryTable.getColumnModel().getColumn(0).setPreferredWidth(0);
        deliveryTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

        add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(556, 119, 530, 410));

        clear.setIcon(new javax.swing.ImageIcon(getClass().getResource("/UI ICONS/xmark.png"))); // NOI18N
        clear.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                clearMouseClicked(evt);
            }
        });
        add(clear, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 90, -1, 20));
        clear.setVisible(false);

        removeFromListButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        removeFromListButton.setText("Delete");
        removeFromListButton.setEnabled(false);
        removeFromListButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeFromListButtonActionPerformed(evt);
            }
        });
        add(removeFromListButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(910, 80, 80, 30));

        saveDeliveryButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        saveDeliveryButton.setText("Save Delivery");
        saveDeliveryButton.setEnabled(false);
        saveDeliveryButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveDeliveryButtonActionPerformed(evt);
            }
        });
        add(saveDeliveryButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(930, 620, 159, 30));

        addToListButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        addToListButton.setText("Add");
        addToListButton.setEnabled(false);
        addToListButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addToListButtonActionPerformed(evt);
            }
        });
        add(addToListButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 620, 110, -1));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel4.setText("Supplier:");
        add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(830, 50, -1, -1));

        deliveryProductFilterSupplierComboBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        deliveryProductFilterSupplierComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        deliveryProductFilterSupplierComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deliveryProductFilterSupplierComboBoxActionPerformed(evt);
            }
        });
        add(deliveryProductFilterSupplierComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 50, 180, -1));

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel5.setText("Supplier:");
        add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, -1, -1));

        deliverySupplierLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        add(deliverySupplierLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(900, 50, 187, 17));

        dateChooserCombo1.setFormat(0);
        dateChooserCombo1.setFieldFont(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 14));
        dateChooserCombo1.addSelectionChangedListener(new datechooser.events.SelectionChangedListener() {
            public void onSelectionChange(datechooser.events.SelectionChangedEvent evt) {
                dateChooserCombo1OnSelectionChange(evt);
            }
        });
        add(dateChooserCombo1, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 50, 206, 25));

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel6.setText("Date:");
        add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 50, -1, 25));

        deliverySupplierIDLabel.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        deliverySupplierIDLabel.setText("jLabel7");
        add(deliverySupplierIDLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 90, -1, -1));
        deliverySupplierIDLabel.setVisible(false);

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel7.setText("Category:");
        add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 700, -1, -1));

        productFilterCategoryComboBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        productFilterCategoryComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        productFilterCategoryComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                productFilterCategoryComboBoxActionPerformed(evt);
            }
        });
        add(productFilterCategoryComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 700, 167, -1));

        productTableSearchInput.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        productTableSearchInput.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                productTableSearchInputKeyPressed(evt);
            }
        });
        add(productTableSearchInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 90, 170, -1));

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton1.setText("Search");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 90, 80, -1));

        clearTableButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        clearTableButton.setText("Clear All");
        clearTableButton.setEnabled(false);
        clearTableButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearTableButtonActionPerformed(evt);
            }
        });
        add(clearTableButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(1000, 80, 80, 30));

        editButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        editButton.setText("Edit Quantity");
        editButton.setEnabled(false);
        editButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editButtonActionPerformed(evt);
            }
        });
        add(editButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 80, 160, 30));

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel3.setText("Delivery Receipt :");
        add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 620, -1, -1));

        deliveryReceiptInput.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        add(deliveryReceiptInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 620, 200, -1));

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setText("Remarks:");
        add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 530, -1, -1));

        remarksInput.setColumns(20);
        remarksInput.setRows(5);
        jScrollPane3.setViewportView(remarksInput);

        add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 550, 530, 60));

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 40, 10, 670));

        jButton4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton4.setText("View Delivery History");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(920, 10, -1, -1));

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel11.setText("Current Inventory");
        add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, -1, -1));

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel12.setText("Products Selected");
        add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 90, -1, -1));
    }// </editor-fold>//GEN-END:initComponents

    private void removeFromListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeFromListButtonActionPerformed
        deliveryController.removeSelectedRow();
        InputValidator.enabler2(deliveryTable, clearTableButton);
        InputValidator.enabler2(deliveryTable, saveDeliveryButton);
    }//GEN-LAST:event_removeFromListButtonActionPerformed

    private void saveDeliveryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveDeliveryButtonActionPerformed
        deliveryController.acknowledgeDelivery();
       
    }//GEN-LAST:event_saveDeliveryButtonActionPerformed

    private void addToListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToListButtonActionPerformed
        inputQuantityDialog.setVisible(true);
        //deliveryController.addSelectedToDeliverySummary();
        InputValidator.enabler2(deliveryTable, clearTableButton);
        InputValidator.enabler2(deliveryTable, saveDeliveryButton);
    }//GEN-LAST:event_addToListButtonActionPerformed

    private void deliveryProductFilterSupplierComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deliveryProductFilterSupplierComboBoxActionPerformed
        deliveryController.filterProducts();
    }//GEN-LAST:event_deliveryProductFilterSupplierComboBoxActionPerformed

    private void productFilterCategoryComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_productFilterCategoryComboBoxActionPerformed
        deliveryController.filterProducts();
    }//GEN-LAST:event_productFilterCategoryComboBoxActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        deliveryController.searchProduct();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void clearMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clearMouseClicked
        deliveryController.clearSearch();
        //InputValidator.enabler2(cartTable, jButton2);
       // InputValidator.enabler2(cartTable, clearTableButton);
    }//GEN-LAST:event_clearMouseClicked

    private void clearTableButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearTableButtonActionPerformed
        deliveryController.clearList();
        InputValidator.enabler2(deliveryTable, clearTableButton);
        InputValidator.enabler2(deliveryTable, saveDeliveryButton);
    }//GEN-LAST:event_clearTableButtonActionPerformed

    private void inputQuantityTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inputQuantityTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_inputQuantityTextFieldActionPerformed

    private void inputQuantityTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputQuantityTextFieldKeyPressed
        if (evt.getKeyCode()== KeyEvent.VK_ENTER)
        {
           // inputQuantityTextField.setText("");
            quantityInputButton.doClick();
            inputQuantityTextField.setText("");
        }
    }//GEN-LAST:event_inputQuantityTextFieldKeyPressed

    private void quantityCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quantityCancelButtonActionPerformed
        inputQuantityDialog.setVisible(false);
        inputQuantityTextField.setText("");
    }//GEN-LAST:event_quantityCancelButtonActionPerformed

    private void quantityInputButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quantityInputButtonActionPerformed
        deliveryController.quantityInput();
        inputQuantityTextField.setText("");
        InputValidator.enabler2(deliveryTable, saveDeliveryButton);
        InputValidator.enabler2(deliveryTable, clearTableButton);
    }//GEN-LAST:event_quantityInputButtonActionPerformed

    private void productTableSearchInputKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_productTableSearchInputKeyPressed
        if (evt.getKeyCode()== KeyEvent.VK_ENTER)
        {
            jButton1.doClick();
        }
    }//GEN-LAST:event_productTableSearchInputKeyPressed

    private void editQuantityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editQuantityActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_editQuantityActionPerformed

    private void editQuantityKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_editQuantityKeyPressed
        if (evt.getKeyCode()==KeyEvent.VK_ENTER){
        editQuantityOKButton.doClick();
        }
    }//GEN-LAST:event_editQuantityKeyPressed

    private void editQuantityCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editQuantityCancelActionPerformed
        editQuantityDialog.dispose();
        editQuantity.setText("");
    }//GEN-LAST:event_editQuantityCancelActionPerformed

    private void editQuantityOKButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editQuantityOKButtonActionPerformed
        deliveryController.editQuantityDialog();
        editQuantity.setText("");
    }//GEN-LAST:event_editQuantityOKButtonActionPerformed

    private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
        editQuantityDialog.setVisible(true);
    }//GEN-LAST:event_editButtonActionPerformed

    private void deliveryProductsTableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_deliveryProductsTableKeyPressed
        if (evt.getKeyCode()==KeyEvent.VK_ENTER){
        inputQuantityDialog.setVisible(true);
        }
    }//GEN-LAST:event_deliveryProductsTableKeyPressed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        deliveryController.acknowledgeDelivery();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void inputQuantityDialogWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_inputQuantityDialogWindowClosed
        inputQuantityTextField.setText("");
    }//GEN-LAST:event_inputQuantityDialogWindowClosed

    private void editQuantityDialogWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_editQuantityDialogWindowClosed
        editQuantity.setText("");
    }//GEN-LAST:event_editQuantityDialogWindowClosed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        deliveryController.updateDeliveryHistoryReport();
        deliveryHistoryDialog.setVisible(true);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void dateFromOnSelectionChange(datechooser.events.SelectionChangedEvent evt) {//GEN-FIRST:event_dateFromOnSelectionChange
        deliveryController.updateDeliveryHistoryReport();
    }//GEN-LAST:event_dateFromOnSelectionChange

    private void dateToOnSelectionChange(datechooser.events.SelectionChangedEvent evt) {//GEN-FIRST:event_dateToOnSelectionChange
        deliveryController.updateDeliveryHistoryReport();
    }//GEN-LAST:event_dateToOnSelectionChange

    private void dateChooserCombo1OnSelectionChange(datechooser.events.SelectionChangedEvent evt) {//GEN-FIRST:event_dateChooserCombo1OnSelectionChange
        // TODO add your handling code here:
    }//GEN-LAST:event_dateChooserCombo1OnSelectionChange

    private void dateFromOnCommit(datechooser.events.CommitEvent evt) {//GEN-FIRST:event_dateFromOnCommit
        deliveryController.updateDeliveryHistoryReport();
    }//GEN-LAST:event_dateFromOnCommit

    private void dateToOnCommit(datechooser.events.CommitEvent evt) {//GEN-FIRST:event_dateToOnCommit
        deliveryController.updateDeliveryHistoryReport();
    }//GEN-LAST:event_dateToOnCommit

    public static JTable getDeliveryProductsTable(){
        return deliveryProductsTable;
    }
    
    public static JComboBox<ComboItem> getDeliveryProductFilterSupplierComboBox(){
        return deliveryProductFilterSupplierComboBox;
    }
    
    public static JLabel getDeliverySupplierLabel(){
        return deliverySupplierLabel;
    }
    
    public static JComboBox<ComboItem> getDeliveryProductFilterCategoryComboBox(){
        return productFilterCategoryComboBox;
    }
    
    public static void updateDeliveryHistoryTable(){
        deliveryController.updateDeliveryHistoryReport();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDialog DeliveryReceipt;
    private javax.swing.JButton addToListButton;
    private javax.swing.JLabel clear;
    private javax.swing.JButton clearTableButton;
    private datechooser.beans.DateChooserCombo dateChooserCombo1;
    private datechooser.beans.DateChooserCombo dateFrom;
    private datechooser.beans.DateChooserCombo dateTo;
    private javax.swing.JDialog deliveryHistoryDialog;
    private javax.swing.JTable deliveryHistoryTable;
    private static javax.swing.JComboBox<ComboItem> deliveryProductFilterSupplierComboBox;
    public static javax.swing.JTable deliveryProductsTable;
    private javax.swing.JTextField deliveryReceiptInput;
    private javax.swing.JLabel deliverySupplierIDLabel;
    private static javax.swing.JLabel deliverySupplierLabel;
    private javax.swing.JTable deliveryTable;
    private javax.swing.JButton editButton;
    private javax.swing.JTextField editQuantity;
    private javax.swing.JButton editQuantityCancel;
    private javax.swing.JDialog editQuantityDialog;
    private javax.swing.JButton editQuantityOKButton;
    private javax.swing.JDialog inputQuantityDialog;
    private javax.swing.JTextField inputQuantityTextField;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTextField1;
    private static javax.swing.JComboBox<ComboItem> productFilterCategoryComboBox;
    private javax.swing.JTextField productTableSearchInput;
    private javax.swing.JButton quantityCancelButton;
    private javax.swing.JButton quantityInputButton;
    private javax.swing.JTextArea remarksInput;
    private javax.swing.JButton removeFromListButton;
    private javax.swing.JButton saveDeliveryButton;
    // End of variables declaration//GEN-END:variables
}
